/*     */ package com.qmsk.business.info.regmedtype.controller;
/*     */ 
/*     */ import com.qmsk.business.info.regmedtype.dao.RegmedTypeDAO;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/regMed"})
/*     */ public class RegmedTypeController
/*     */ {
/*  30 */   private static final Logger logger = Logger.getLogger(RegmedTypeController.class);
/*     */ 
/*     */   @Autowired
/*     */   private RegmedTypeDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  49 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  51 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  52 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  54 */       logger.error(e);
/*  55 */       ResponseUtils.setErrorMsgResponse(
/*  56 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  74 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  76 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/*  77 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  79 */       logger.error(e);
/*  80 */       ResponseUtils.setErrorMsgResponse(
/*  81 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id)
/*     */   {
/*     */     try
/*     */     {
/*  98 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(id);
/*  99 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 101 */       logger.error(e);
/* 102 */       ResponseUtils.setErrorMsgResponse(
/* 103 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/ltId/{ltId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfLargeTypeId(HttpServletRequest request, HttpServletResponse response, @PathVariable("ltId") String ltId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 123 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 125 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(ltId, nPageIdx, nPageSize);
/* 126 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 128 */       logger.error(e);
/* 129 */       ResponseUtils.setErrorMsgResponse(
/* 130 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 146 */       int nResult = 0;
/* 147 */       Long id = null;
/* 148 */       String sData = RequestUtils.getStringOfData(request);
/* 149 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 150 */       if (p != null) {
/* 151 */         nResult = this.dao.applyUpdates(p);
/* 152 */         if (nResult > 0) {
/* 153 */           id = this.dao.getLastId();
/* 154 */           DbConnection.commit();
/*     */         } else {
/* 156 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 159 */       if (id != null) {
/* 160 */         String[] heads = { "id" };
/* 161 */         Object[] datas = { id };
/* 162 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/* 163 */         return; }
/* 164 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 165 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 166 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 169 */       logger.error(e);
/* 170 */       DbConnection.rollback();
/* 171 */       ResponseUtils.setErrorMsgResponse(
/* 172 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 173 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 189 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 191 */       String[] strParams = id.split(",");
/* 192 */       int nResult = this.dao.deleteParams(strParams);
/* 193 */       DbConnection.commit();
/* 194 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 195 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 196 */         response);
/*     */     } catch (Exception e) {
/* 198 */       DbConnection.rollback();
/* 199 */       logger.error(e);
/* 200 */       ResponseUtils.setErrorMsgResponse(
/* 201 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 202 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 219 */       int nResult = 0;
/* 220 */       String sData = RequestUtils.getStringOfData(request);
/* 221 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 222 */       if (p != null) {
/* 223 */         nResult = this.dao.applyUpdates(p);
/* 224 */         if (nResult > 0)
/* 225 */           DbConnection.commit();
/*     */         else {
/* 227 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 230 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 231 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 232 */         response);
/*     */     } catch (Exception e) {
/* 234 */       DbConnection.rollback();
/* 235 */       logger.error(e);
/* 236 */       ResponseUtils.setErrorMsgResponse(
/* 237 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 238 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.regmedtype.controller.RegmedTypeController
 * JD-Core Version:    0.5.3
 */